<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
	<button onclick="Create_Code()">生成验证码</button>
	<div id="odv" style="width:140px;height: 40px;background-color: #ccc;border: 1px solid #000;font-size:30px;font-olign:center;"></div>

</body>
</html>
<script>
	function Create_Code(){
		var odv = document.getElementById('odv');
		var arr = [];
		for(var i=0;i<4;i++){
			var num = (parseInt(Math.random()*123));
			if (num>=0 && num<=9) {
				arr.push(num)
			}else if (num>=65 &&num<=90) {
				arr.push(String.fromCharCode(num));
			}else if (num>=97 &&num<=122) {
				arr.push(String.fromCharCode(num));
			}else{
				i
			}
		}
		odv.innerHTML = arr.join("");

	}

	//document.write(Create_Code(4))

</script>